package com.huodongjia.mapper;

import com.huodongjia.pojo.Join;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface JoinMapper {

    @Insert("insert into huodongjia.`join`(join_id, activity_id) values (#{userId},#{activityId})")
    void insert(int userId, int activityId);

    @Select("select * from huodongjia.`join` where join_id=${userId} AND activity_id=${activityId}")
    List<Join> isJoin(int userId, int activityId);

    @Delete("delete from huodongjia.`join` where join_id=${userId} and activity_id=${activityId}")
    void delete(int userId, int activityId);

    @Select("select * from huodongjia.`join` where activity_id=${activityId}")
    List<Join> findByActivityId(int activityId);
    @Delete("delete from huodongjia.`join` where activity_id=${activityId}")
    void deleteByActivity(int activityId);
}
